cmake_minimum_required(VERSION 3.14)
project(JavaKtRefactorDiff VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Core Gui)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Core Gui)

set(SOURCES
    main.cpp
    mainwindow.cpp
    filecomparator.cpp
    diffhighlighter.cpp
    syncdialog.cpp
)

set(HEADERS
    mainwindow.h
    filecomparator.h
    diffhighlighter.h
    syncdialog.h
)

set(FORMS
    mainwindow.ui
    syncdialog.ui
)

add_executable(JavaKtRefactorDiff ${SOURCES} ${HEADERS} ${FORMS})

# 为Visual Studio编译器添加/utf-8编译选项
if(MSVC)
    target_compile_options(JavaKtRefactorDiff PRIVATE /utf-8)
endif()

target_link_libraries(JavaKtRefactorDiff PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Gui)

install(TARGETS JavaKtRefactorDiff DESTINATION bin)